import { reactive } from "vue";
import { api } from 'boot/axios'
import { CommonApiPrefix } from 'src/common/const'
/**
 * @description 获取经销商下有效的部门
 * 
 * */
export const useValidateDepartmentList = () => {

  const list = reactive<any[]>([])
  const fetchData = async () => {
    try {
      const res = await api.get(`${CommonApiPrefix}/department/list`);
      list.push(...res.data.map((item: any) => {
        const { id, name } = item
        return {
          value: id,
          label: name
        }
      }))
    } catch (error) {
      console.log(error);
    }
  }
  fetchData();
  return [list];
};
